package JUC.lock;

import java.util.concurrent.TimeUnit;

/**
 * @author mubei
 * @date 2021/11/21
 * @description
 */
public class Test2 {


    public static void main(String[] args) {

        Phone2 phone = new Phone2();
        Phone2 phone1 = new Phone2();
        new Thread(()-> phone.sendSms(),"A").start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()-> phone1.call(),"A").start();
    }

}


class Phone2{


    public static synchronized void sendSms() {
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("发短信");
    }

    public static synchronized void call(){
        System.out.println("call");
    }
}
